package com.ruoyi.systemapp.utils;

import com.google.protobuf.ByteString;
import com.ruoyi.systemapp.netty.NettyServerHandler;
import com.ruoyi.systemapp.service.MeesageHandler;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

/**
 * Author:cgChen
 * Date:2022/05/16 17:38
 * Description:通过注解实现任务分发
 */
@Configurable
@Component
public class Disroute{
    @Autowired
    private ApplicationContext applicationContext;

    public byte[] onMessage(byte[] message, int code){
        /*获取状态对应的实现*/
        MeesageHandler handler = applicationContext.getBean("cmd=" + code,MeesageHandler.class);
        byte[] result = handler.process(message);
        return result ;
        /*会根据message里面的cmd的值调用不同的方法*/
        //return Route.dispatch(message);
    }

}
